<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
    <title>修改员工</title>
    <link rel="stylesheet" type="text/css" href="Assets/css/reset.css"/>
    <script type="text/javascript" src="Assets/js/jquery-1.8.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="Assets/plugins/FlexSlider/flexslider.css">
    <script type="text/javascript" src="Assets/plugins/FlexSlider/jquery.flexslider.js"></script>
    <script type="text/javascript" src="Assets/js/main.js"></script>
    <link rel="stylesheet" type="text/css" href="Assets/css/thems.css">
    <link rel="stylesheet" type="text/css" href="Assets/css/responsive.css">
    <!-- -------------------------------------------------- -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <script language="javascript">

    </script>
</head>

<body>
<!--头部-->
<div class="head clearfix">
    <div class="logo"><a href=""><img src="Assets/images/logo.jpg" alt="信本财富"/></a></div>
    <div class="head_r">
        <div class="lang">
            <a href="">中文</a>|
        </div>
        <ul class="nav clearfix">
            <li class="now"><a href="index.html">首页</a></li>
            <li><a href="product.html">课程管理</a></li>
            <li><a href="vip.html">会员管理</a></li>
            <li><a href="sig_in.html">签到管理</a></li>
            <li><a href="custom-made.html">定制会员卡</a></li>
            <li><a href="subbranch.html">场馆管理</a></li>
            <li><a href="staff.html">员工管理</a></li>
        </ul>
        <div class="nav_m">
            <span class="n_icon">&nbsp;</span>
            <ul>
                <li><a href="index.html">首页</a></li>
                <li><a href="about.html">关于信本</a></li>
                <li><a href="news.html">信本动态</a></li>
                <li class="now"><a href="product.html">信本业务</a></li>
                <li><a href="#">信本学院</a></li>
                <li><a href="#">社会责任</a></li>
                <li><a href="#">联系我们</a></li>
            </ul>
        </div>
    </div>
</div>
<!--头部-->
<!--幻灯片-->
<div class="banner">
    <div class="slider">
        <div class="flexslider">
            <ul class="slides">
                <li>
                    <a href=""><img src="Assets/upload/banner.jpg" alt="" /></a>
                </li>
                <li>
                    <a href=""><img src="Assets/upload/banner_a.jpg" alt="" /></a>
                </li>
                <li>
                    <a href=""><img src="Assets/upload/banner_b.jpg" alt="" /></a>
                </li>
                <li>
                    <a href=""><img src="Assets/upload/banner_c.jpg" alt="" /></a>
                </li>
                <li>
                    <a href=""><img src="Assets/upload/banner_d.jpg" alt="" /></a>
                </li>
            </ul>
        </div>
    </div>
</div>
<!--幻灯片-->
<div class="scd clearfix">
    <div class="scd_l">
        <div class="title"><span>修改员工</span></div>
        <ul class="s_nav">
            <li><a href=""><em>确定修改</em></a></li>
            <li><a href="staff.html"><em>返回</em></a></li>
        </ul>
    </div>
    <div class="scd_r">
        <div class="s_title">

            <div class="pst">
                当前位置：
                <a href="">首页</a>>
                <a href="">修改员工</a>>
            </div>
        </div>
        <div class="scd_m">
            <div class="pro_d">


                <div class="form-group">
                    <label for="name">姓名</label>
                    <input type="text" class="form-control" id="name"
                           placeholder="请输入名称">
                </div>
                <div class="form-group">
                    <label for="name">手机号</label>
                    <input type="text" class="form-control" id="staffphone1"
                           placeholder="请输入名称">
                </div>

                <div class="form-group">
                    <label for="name">性别</label>
                    <select name="" id="staffsex1">
                        <option value="男">男</option>
                        <option value="女">女</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="name">角色</label>
                    <select name="" id="staffrole1">
                        <option value="教练">教练</option>
                        <option value="店长">店长</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="name">是否支持私教</label>
                    <select name="" id="staffsupport1">

                        <option value="支持">支持</option>
                        <option value="不支持">不支持</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="name">店铺</label>
                    <select name="" id="shopid">

                    </select>
                </div>



                <div class="form-group">
                    <label for="inputfile">照片选择</label>
                    <form method="post" id="file1" enctype="multipart/form-data">
                        <input type="file" id="inputfile" name="file">
                    </form>
                    <img src="" id="img1" width="400px" height="300px">
                </div>

                <button type="submit" class="btn btn-default" onclick="update1()">修改</button>



            </div>
        </div>
    </div>
</div>

</body>
</html>
<script>


    var id;
    var staffname1;
    var staffphone1;
    var staffsex1;
    var staffrole1;
    var staffsupport1;
    var staffimg1;
    var shopid;
    var path = "/" + location.pathname.split("/")[1];
    $(function () {

        var thisURL = document.URL;
        var getval = null;
        //判断是不是带有id的请求
        if (thisURL.search("id=") != -1) {
            getval = thisURL.split('?')[1];
            id = getval.split("=")[1];
        }
        var path = "/" + location.pathname.split("/")[1];
        $.get(path+"/staffQuery2",{"staffid":id},function (list2) {

            $.each(list2,function (i2,li2) {

                staffname1 = li2.staffname;
                staffphone1 = li2.staffphone;
                staffsex1 = li2.staffsex;
                staffrole1  = li2.staffrole;
                staffsupport1 = li2.staffsupport;
                staffimg1 = li2.staffimg;
                shopid  = li2.shopid.shopid;

                $("#name").val(staffname1);
                $("#staffphone1").val(staffphone1);
                $("#staffsex1").val(staffsex1);
                $("#staffrole1").val(staffrole1);
                $("#staffsupport1").val(staffsupport1);
                $("#shopid").val(shopid);
                var paths= path+"/"+staffimg1;
                console.log(paths+"==============");
                $("#img1").attr("src",paths);


            });

        },"json");

        var path = "/" + location.pathname.split("/")[1];

        $.get(path+"/shopQuery",function (list) {
            console.log(list+"=================")

            $.each(list,function (i,li) {

                console.log(li)

                $("#shopid").append(

                    '<option value='+li.shopid+'>'+li.shopname+'</option>'

                );

            });

        },"json");






        var s;
        $("#inputfile").change(function () {
            var path = "/" + location.pathname.split("/")[1];
            /*  var data  =  new FormData($("#file1")[0]);
              console.log(data+"==============");*/

            var formData = new FormData($('#file1')[0]);
            console.log(formData);

            $.ajax({
                type: "post",
                url:path+"/FileImg",
                data: formData,
                cache: false,
                processData: false,
                contentType: false,
                beforeSend:function(){

                },
                success: function(msg){
                    alert( "Data Saved: " + msg );
                    s = eval(msg);
                    staffimg1 =s;

                    var paths= path+"/"+staffimg1;
                    console.log(paths+"======图片+========");
                    $("#img1").attr("src",paths);
                    var pathss = $("#img1")[0].src;
                    console.log(pathss+"======图片+========");

                },
                error:function(){

                }
            });


        });


    });


</script>
<script type="text/javascript">


    function update1() {

        staffname1 = $("#name").val();
        staffphone1= $("#staffphone1").val();
        staffsex1 = $("#staffsex1").val();
        staffrole1 = $("#staffrole1").val();
        staffsupport1= $("#staffsupport1").val();
        shopid = $("#shopid").val();


        $.get(path+"/staffUpdate",{"staffid":id,"staffname":staffname1,"staffphone":staffphone1,"staffsex":staffsex1,"staffrole":staffrole1,"staffsupport":staffsupport1,"staffimg":staffimg1,"shopid":shopid},function (list) {
            var li= eval(list);
            console.log(li+"===============");
            if (li){
                window.location.href="staff.html"
            } else {
                alert("修改失败")

            }


        },"json");

    }

</script>